package com.cw.demo.netty.server;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;

/**
 * TODO
 *
 * @author chenw
 * @date 2021/1/7
 */
@Slf4j
public class RpcServerHandler extends SimpleChannelInboundHandler<String> {

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, String s) throws Exception {
        log.info("server channel read");
        log.info(ctx.channel()
            .remoteAddress() + "to server:" + s);
        ctx.write("server write 你好客户端，我是netty服务端");
        ctx.flush();
    }
}
